Method and system for monitoring and verifying software drivers using system resources including memory allocation and access

ABSTRACT

A method and system for verifying computer system drivers such as kernel mode drivers. A driver verifier sets up tests for specified drivers and monitors the driver&#39;s behavior for selected violations that cause system crashes. In one test, the driver verifier allocates a driver&#39;s memory pool allocations from a special pool bounded by inaccessible memory space for testing the driver&#39;s accessing memory outside of the allocation. The driver verifier also marks the space as inaccessible when it is deallocated, detecting a driver that accesses deallocated space. The driver verifier may also provide extreme memory pressure on a specific driver, or randomly fail requests for pool memory. The driver verifier also checks call parameters for violations, performs checks to ensure a driver cleans up timers when deallocating memory and cleans up memory and other resources when unloaded. An I/O verifier is also described for verifying drivers use of I/O request packets.

FIELD OF THE INVENTION

The invention relates generally to computer systems, and moreparticularly to an improved method and system for monitoring andverifying software components such as kernel-mode drivers.

BACKGROUND OF THE INVENTION

In contemporary operating systems such as Microsoft Corporation'sWindows® 2000, low-level (i.e., kernel mode) components includingdrivers and the operating system itself, handle critical systemoperations. At the same time, for performance and architectural reasons,drivers typically load in an environment where any driver memory isaccessible by any other driver. Furthermore, performance requirementskeep operating system overhead to a minimum. Consequently, suchcomponents are highly privileged in the operations that they are allowedto perform, and moreover, do not have the same protection mechanisms ashigher level (i.e., user mode) components. As a result, even theslightest error in a kernel component can corrupt the system and cause asystem crash.

Determining the cause of a system crash so that an appropriate fix maybe made has heretofore been a difficult, labor-intensive and somewhatunpredictable task, particularly since the actual component responsiblefor corrupting the system often appears to be substantially unrelated tothe problem. For example, one way in which a kernel component can causea system crash is related to the way in which pooled memory is arrangedand used. For many reasons, including performance and efficiency, pooledmemory is allocated by the system kernel as a block, (e.g., in multiplesof thirty-two bytes), with a header (e.g., eight bytes) at the start ofeach block. For example, if forty-four bytes of pooled memory arerequired by a driver, sixty-four are allocated by the kernel, eight forthe header, forty-four for the driver, with the remaining twelve unused.Among other information, the header includes information that tracks theblock size. Then, when the memory is deallocated, the kernel looks tosee if this block may be coalesced with any adjacent deallocated blocks,so that larger blocks of memory become available for future requests. Ifso, the header information including the block size is used to coalescethe adjacent blocks.

However, while this mechanism is highly efficient in satisfying requestsfor memory allocations and then recombining deallocated memory, if anerrant kernel component writes beyond its allocated memory block, itoverwrites the header of the subsequent block. For example, if a driverrequests twenty-four bytes, it will receive one thirty-two byte block,eight for the header followed by the requested twenty-four bytes.However, if the driver writes past the twenty-fourth byte, the driverwill corrupt the next header, whereby the kernel may, for example, latercoalesce the next block with an adjacent block even though the nextblock may be allocated to another kernel component. As can beappreciated, other types of errors may result from the corrupted header.In any event, the kernel or the component having the next blockallocated to it (or even an entirely different component) will likelyappear responsible for the crash, particularly if the problem caused bythe errant driver in overwriting the header does not materialize untillong after the errant driver has deallocated its memory block.

Another way in which an errant driver may crash the system is when adriver frees pooled memory allocated thereto, but then later writes toit after the memory has been reallocated to another component,corrupting the other component's information. This may lead to a crashin which the other component appears responsible. Indeed, thispost-deallocation writing can be a very subtle error, such as if theerroneous write occurs long after the initial deallocation, possiblyafter many other components have successfully used the same memorylocation. Note that such a post-deallocation write may also overwrite aheader of another block of pooled memory, e.g., when smaller blocks arelater allocated from a deallocated larger block.

Yet another type of error that a kernel component may make is failing todeallocate memory that the component no longer needs, often referred toas a “memory leak.” This can occur, for example, when a driver unloadsbut still has memory allocated thereto, or even when a driver is loadedbut for some reason does not deallocate unneeded memory. Note that thiscan occur because of the many complex rules drivers need to follow inorder to safely interact with other drivers and operating systemcomponents. For example, if two related components are relying on eachother to deallocate the space, but neither component actually doesdeallocate it, a memory leak results. Memory leaks can be difficult todetect, as they slowly degrade machine performance until anout-of-memory error occurs.

Other kernel component errors involve lists of resources maintained bythe kernel to facilitate driver operations, and the failure of thedriver to properly delete its listed information when no longer needed.For example, a driver may request that the kernel keep timers forregularly generating events therefor, or create lookaside lists, whichare fixed-sized blocks of pooled memory that can be used by a driverwithout the overhead of searching the pool for a matching size block,and thus are fast and efficient for repeated use. A driver may also failto delete pending deferred procedure calls (DPCs), worker threads,queues and other resources that will cause problems when the driverunloads. Moreover, even when still loaded, the driver should deleteitems when no longer needed, e.g., a timer maintained by the kernel fora driver may cause a write to a block of memory no longer allocated tothe driver. Other errors include drivers incorrectly specifying theinterrupt request level (IRQL) for a requested operation, and spinlockerrors, i.e., errors related to a mechanism via which only one processorin a multi-processor system can operate at a time, while a driver incontrol of the spinlock uses the operational processor to execute acritical section of code that cannot be interrupted. Furthercomplicating detection of the above errors, and identification of theirsource, is that the errors are often difficult to reproduce. Forexample, a driver may have a bug that does not arise unless memory islow, and then possibly only intermittently, whereby a test system willnot reproduce the error because it does not reproduce the conditions.

In sum, kernel components such as drivers need to be privileged, whichmakes even slight errors therein capable of crashing the system, yetsuch errors are often difficult to detect, difficult to match to thesource of the problem and/or difficult to reproduce.

SUMMARY OF THE INVENTION

Briefly, the present invention provides a method and system that enablesmonitoring of user-specified kernel mode components, to watch for selecterrors committed thereby. To this end, a kernel mode component such as adriver is identified to the kernel at the time the driver is loaded,along with information identifying the type or types of errors for whichthe driver is to be monitored. Calls by the identified driver to thekernel are re-vectored to a driver verifier component in the kernel, andthe driver verifier component takes actions to monitor the driver basedon the type or types of monitoring selected for that driver.

Actions that may be taken by the driver verifier include satisfyingdriver memory pool allocation requests from a special pool that isisolated and bounded by no access permissions. This ascertains whether adriver allocates a certain number of bytes and accesses bytes outside ofthat allocation. When a driver deallocates space, the space is marked as“No Access” to detect drivers that later access the deallocated space.Also, pool being freed is examined to ensure that no pending timers areinside the pool allocation.

The driver verifier may also be enabled to track a driver's use ofpooled memory. To this end, the driver verifier maintains datastructures that record information about each allocation, appropriatelyupdating the information as memory is allocated and deallocated. Whenthe driver is unloaded, the driver verifier checks that the driver'sspace is all deallocated, otherwise a memory leak is detected. Driverunload checking also detects drivers that unload without deleting kernelresources including lookaside lists, pending deferred procedure calls(DPCs), worker threads, queues, timers and other resources.

The driver verifier may also be enabled to simulate low resourceconditions. One way to simulate low resource conditions is to provideextreme memory pressure on a specific driver, without affecting otherdrivers, and regardless of system memory size. This is accomplished byinstructing memory management to invalidate the driver's pageable codeand data, as well as system paged pool, code and data. This catchesdrivers that incorrectly hold spinlocks or raise the interrupt requestlevel, and then access paged code or data. Another way in which thedriver verifier may simulate low resource conditions to force drivererrors is by randomly failing requests from the driver for pooledmemory, thereby determining whether a driver can handle this low memorysituation.

Further, the driver verifier validates the parameters of a kernelfunction call, whereby errors in spinlock, IRQL and pool allocationcalls are detected. Input/Output (I/O) verification may also beselectively enabled.

Other advantages will become apparent from the following detaileddescription when taken in conjunction with the drawings, in which:

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram representing a computer system into which thepresent invention may be incorporated;

FIG. 2 is a block diagram generally representing a general architecturefor monitoring drivers in accordance with an aspect of the presentinvention;

FIG. 3A is a block diagram generally representing the monitoring of adriver via a special memory pool allocation in accordance with an aspectof the present invention;

FIG. 3B is a block diagram generally representing the monitoring of adriver after deallocation of the memory pool allocation of FIG. 3A inaccordance with an aspect of the present invention;

FIG. 4 is a block diagram generally representing a special memory pooland illustrating the reuse of virtual memory therein in accordance withan aspect of the present invention;

FIG. 5 is a block diagram generally representing driver verification bytracking drivers' pool allocations in accordance with an aspect of thepresent invention;

FIG. 6 is a block diagram generally representing data structures usedfor tracking drivers' pool allocations in accordance with an aspect ofthe present invention;

FIG. 7 is a representation of a user interface screen showing globalcounters tracking drivers' pool allocations in accordance with an aspectof the present invention;

FIG. 8 is a block diagram generally representing verification ofresource cleanup at driver unload in accordance with an aspect of thepresent invention;

FIG. 9 is a block diagram generally representing verification ofparameters on driver calls to the kernel in accordance with an aspect ofthe present invention;

FIG. 10 is a block diagram generally representing verification ofsubcomponents of other drivers in accordance with an aspect of thepresent invention;

FIG. 11 is a flow diagram generally representing a determination ofwhether to re-vector a driver's call in accordance with an aspect of thepresent invention;

FIGS. 12–15 comprise a flow diagram generally representing tests set upand performed to verify a driver in accordance with an aspect of thepresent invention; and

FIG. 16 is a block diagram generally representing verification of I/Orequests in accordance with an aspect of the present invention.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT

Exemplary Operating Environment

FIG. 1 and the following discussion are intended to provide a briefgeneral description of a suitable computing environment in which theinvention may be implemented. Although not required, the invention willbe described in the general context of computer-executable instructions,such as program modules, being executed by a personal computer.Generally, program modules include routines, programs, objects,components, data structures and the like that perform particular tasksor implement particular abstract data types.

Moreover, those skilled in the art will appreciate that the inventionmay be practiced with other computer system configurations, includinghand-held devices, multi-processor systems, microprocessor-based orprogrammable consumer electronics, network PCs, minicomputers, mainframecomputers and the like. The invention may also be practiced indistributed computing environments where tasks are performed by remoteprocessing devices that are linked through a communications network. Ina distributed computing environment, program modules may be located inboth local and remote memory storage devices.

With reference to FIG. 1, an exemplary system for implementing theinvention includes a general purpose computing device in the form of aconventional personal computer 20 or the like, including a processingunit 21, a system memory 22, and a system bus 23 that couples varioussystem components including the system memory to the processing unit 21.The system bus 23 may be any of several types of bus structuresincluding a memory bus or memory controller, a peripheral bus, and alocal bus using any of a variety of bus architectures. The system memoryincludes read-only memory (ROM) 24 and random access memory (RAM) 25. Abasic input/output system 26 (BIOS), containing the basic routines thathelp to transfer information between elements within the personalcomputer 20, such as during start-up, is stored in ROM 24. The personalcomputer 20 may further include a hard disk drive 27 for reading fromand writing to a hard disk, not shown, a magnetic disk drive 28 forreading from or writing to a removable magnetic disk 29, and an opticaldisk drive 30 for reading from or writing to a removable optical disk 31such as a CD-ROM or other optical media. The hard disk drive 27,magnetic disk drive 28, and optical disk drive 30 are connected to thesystem bus 23 by a hard disk drive interface 32, a magnetic disk driveinterface 33, and an optical drive interface 34, respectively. Thedrives and their associated computer-readable media provide non-volatilestorage of computer readable instructions, data structures, programmodules and other data for the personal computer 20. Although theexemplary environment described herein employs a hard disk, a removablemagnetic disk 29 and a removable optical disk 31, it should beappreciated by those skilled in the art that other types of computerreadable media which can store data that is accessible by a computer,such as magnetic cassettes, flash memory cards, digital video disks,Bernoulli cartridges, random access memories (RAMs), read-only memories(ROMs) and the like may also be used in the exemplary operatingenvironment.

A number of program modules may be stored on the hard disk, magneticdisk 29, optical disk 31, ROM 24 or RAM 25, including an operatingsystem 35 (preferably Windows® 2000), one or more application programs36, other program modules 37 and program data 38. A user may entercommands and information into the personal computer 20 through inputdevices such as a keyboard 40 and pointing device 42. Other inputdevices (not shown) may include a microphone, joystick, game pad,satellite dish, scanner or the like. These and other input devices areoften connected to the processing unit 21 through a serial portinterface 46 that is coupled to the system bus, but may be connected byother interfaces, such as a parallel port, game port or universal serialbus (USB). A monitor 47 or other type of display device is alsoconnected to the system bus 23 via an interface, such as a video adapter48. In addition to the monitor 47, personal computers typically includeother peripheral output devices (not shown), such as speakers andprinters.

The personal computer 20 may operate in a networked environment usinglogical connections to one or more remote computers, such as a remotecomputer 49. The remote computer 49 may be another personal computer, aserver, a router, a network PC, a peer device or other common networknode, and typically includes many or all of the elements described aboverelative to the personal computer 20, although only a memory storagedevice 50 has been illustrated in FIG. 1. The logical connectionsdepicted in FIG. 1 include a local area network (LAN) 51 and a wide areanetwork (WAN) 52. Such networking environments are commonplace inoffices, enterprise-wide computer networks, Intranets and the Internet.

When used in a LAN networking environment, the personal computer 20 isconnected to the local network 51 through a network interface or adapter53. When used in a WAN networking environment, the personal computer 20typically includes a modem 54 or other means for establishingcommunications over the wide area network 52, such as the Internet. Themodem 54, which may be internal or external, is connected to the systembus 23 via the serial port interface 46. In a networked environment,program modules depicted relative to the personal computer 20, orportions thereof, may be stored in the remote memory storage device. Itwill be appreciated that the network connections shown are exemplary andother means of establishing a communications link between the computersmay be used.

Note that the present invention is described herein with respect to theWindows® 2000 (formerly Windows® NT®) operating system. However, as canbe readily appreciated, the present invention is not limited to anyparticular operating system, but rather may be used with any operatingsystem, and moreover, has many uses in general computing.

Driver Verification

As will be understood, the present invention is primarily directed tothe selective monitoring of drivers for detecting certain types oferrors therein, thereby ultimately verifying (to a substantialprobability) that a driver makes none of the errors for which tests areperformed. Thus, for purposes of simplicity, the component (orcomponents) being monitored for verification will ordinarily bedescribed as a “driver” (or “drivers”). Nevertheless, it should beunderstood that the present invention is capable of monitoring of othercomponents, including the kernel itself, and as described below, may beextended via APIs or the like to other components to provideverification functionality for their subcomponents that do not directlycall the kernel. Moreover, as will be understood, the present inventionis extensible in another way, in that as additional tests for driversare developed, those tests may be added to the present architecture thatenables the selective monitoring of drivers.

Turning to the drawings and referring first to FIG. 2, there is shown ageneral architecture into which the present invention may beincorporated. A user such as a program tester, system administrator or adeveloper debugging code accesses a user interface 60 to select one ormore drivers to be tested along with one or more tests (described below)to be performed thereon. The user interface 60 then writes thisdriver/test information into the system registry 62. Note that the usermay alternatively edit the registry 62 directly via the registry editor(e.g., regedt32), by setting the REG_SZ key“\\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet \Control\SessionManager\Memory Management\VerifyDrivers” to the name of the driver(e.g., Ntfs.sys) that is to be monitored/verified. Note that multipledrivers can be specified, however using only one driver at a timeprovides benefits, e.g., by ensuring that available system resources arenot prematurely depleted, since premature depleting resources may causethe bypassing of some driver verification due to lack of resources.

The type of verification may be specified in the REG_DWORD key“\\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet \Control\SessionManager\Memory Management\VerifyDriverLevel.” The bitfield values forthis key (which can be freely combined) are shown as hexadecimal inTABLE 1, and represent the type of tests to perform, in accordance withthe present invention and as described in detail below:

TABLE 1 0x01 Attempt to satisfy all of this driver's allocations from aspecial memory pool. 0x02 Apply memory pressure to this driver tovalidate IRQL usage in regards to accessing pageable code and data. 0x04Randomly fail various pool allocation requests. Note this is only doneafter the system has booted to a point wherein these failures can betreated as reasonable situations to be handled. 0x08 Enable poolallocation tracking. Every allocation must be freed before the driverunloads, or the system will bug check. 0x10 Enable the I/O verifier

The default value is three (3) if the key does not exist or no level ofdriver verification is specified. Lastly, verification may be executedvia a command line.

As shown in FIG. 2, the kernel 64 maintains a copy 66 of the registry,and when a driver is loaded, a driver re-vectorer subcomponent 68accesses the registry copy 66 to determine whether the loaded driver hasbeen specified as one to be monitored/verified. If so, the driverre-vectorer 68 will re-vector any calls from that driver to the kernel64 to a driver verifier component 70, to specially test and monitor thedriver in accordance with the present invention. For efficiency, thedriver re-vectorer 68 may maintain a driver verify information table 72or the like so that when drivers call the kernel 64, those drivers to beverified may be quickly identified and re-vectored to the driververifier 70, along with any information the driver verifier 70 needs toperform the testing.

In accordance with one aspect of the present invention and as generallyrepresented in FIG. 3A, one of the tests that may be performed by thedriver verifier 70 is the detection of memory corruption via writing toa section not allocated to the driver, i.e., memory misuse by overrunsand underruns. To detect memory corruption, the driver verifier 70allocates driver memory from a special pool, and monitors that pool forincorrect access. More particularly, when a driver-to-be-tested 74requests pooled memory from the kernel 64, the re-vectorer 68 re-vectorsthe call to the driver verifier 70. If the “special memory pool” bit isactive, (and a global flag is set to overrun detection), each memoryallocation requested by the driver 70 is placed on a separate page (thatis not pageable to disk). To this end, as shown in FIG. 3A, the driververifier 70 returns a virtual address 76 to the driver 74 that is thehighest possible address which allows the allocation to fit on the page,in a virtual memory page pool 80, whereby the allocated memory isaligned with the end of the page. Note that an allocation may spanmultiple pages, however at present, only requests less than a page areput into subblocks (and can be special pooled/verified). Further notethat a full page is allocated even when less than a full page isrequested. The remainder of the page that precedes the data, if any, iswritten with random data, which may comprise a recorded pattern or thelike to detect underruns.

To detect overruns, the previous page and the next page in the page pool80 are marked inaccessible. Note that this is accomplished in Windows®2000 via virtual memory management, wherein each virtual address isassociated with a page table entry which comprises a physical address towhich the virtual address maps, along with bits that control pageaccess. Thus, the surrounding pages are marked “No Access” by the driververifier 70 via the bit settings. Virtual memory management is furtherdescribed in the references, “Inside Windows NT®,” by Helen Custer,Microsoft Press (1993); and “Inside Windows NT®, Second Edition” byDavid A. Solomon, Microsoft Press (1998), hereby incorporated byreference herein.

Attempts to access memory beyond the allocation buffer (within a page)are immediately detected as an access violation, as such an access iswithin the subsequent, “No Access” memory page. Note that writing beforethe beginning of the buffer will (presumably) alter the random data, andwhen the buffer is freed, this alteration will be detected. In eithercase, a bug check (e.g., having a value of 0xC1 in one implementation)is issued, whereby the user can debug (or record for later debugging)the error. In keeping with the present invention, the immediateviolation detection of overruns helps identify the errant driver.

Note that when underrun detection is selected for drivers, (via theglobal flag), the allocated memory is instead aligned with the beginningof the page. With this setting, underruns cause an immediate bug check,while overruns (may) cause a bug check when the memory is freed. Inactual implementations, underrun errors tend to occur less often thenoverrun errors.

Further, note that each allocation from the special pool 80 uses onepage of non-pageable memory and two pages of virtual address space,burdening system resources. If the special pool 80 is exhausted, memoryis allocated in the standard way until the special pool 80 becomesavailable again, and thus depending on a system's resources, verifyingmultiple drivers in this manner at the same time may cause errors to bemissed. A debugger extension can be used to monitor special pool use,and report whether the special pool covered all memory allocations orwhether the special pool was exhausted. Note that the size of the poolmay be automatically or manually configured based on the amount ofphysical memory on the system.

Another test of memory misuse that the driver verifier 70 performs isrepresented in FIG. 3B, whereby when the driver 74 deallocates memoryfrom the special pool 80, instead of freeing the virtual address space,the entire section is marked “No access.” As a result, any subsequentread or write back to the formerly allocated area is also detected viaan access violation.

However, because memory space is finite, the system needs to reuse thespecial pool 80 at some time. To this end, as shown in FIG. 4, thespecial pool is essentially arranged as a queue with respect to thedeallocated pages. More particularly, once deallocated, a page is reusedonly after cycling through a large number (e.g., 50,000 or more) ofallocations to other areas of the pool 80. To this end, the driververifier 70 may maintain a pointer or the like to the appropriatevirtual address in the pool 80, e.g., the address of the virtual nextlocation in which space for allocating and bounding the allocated pageis available. Note that a page that is still allocated and itssurrounding “No Access” pages are skipped over such that onlydeallocated pages are reused.

In accordance with another aspect of the present invention, other typesof incorrect usage of pooled memory may also be detected for a specifieddriver. A first way in which an error may occur is by having a pendingtimer remain in deallocated pool. To detect this, the driver verifier 70examines the memory pool deallocated by a driver being verified, and iftimers are found, the driver verifier issues a bug check (e.g., 0xC7).

Memory leaks are also a misuse of pooled memory, and the driver verifier70 may be selectively enabled to test for such errors. To this end, asrepresented in FIGS. 5 and 6, when this option is enabled for a driver74 ₁, the driver verifier 70 initially sets up two data structures, averification block 82 ₁ and an outstanding allocation table 84 ₁, totrack the pool allocations for that driver 74 ₁. Note that multipleverification blocks 82 ₁–82 _(n) and outstanding allocation tables 84₁–84 _(n) may be set up, one for each driver having pool allocationtracking enabled. Further note that pool tracking is independent of theabove-described memory usage testing, and thus may track regular poolallocations or special pool allocations.

As generally represented in FIG. 6, the verification block (e.g., 82 ₁)comprises driver information including a count of the total allocationsfor this driver. Other information may be maintained in the verificationblock, such as various allocation information for this driver, shown inthe user interface 60 displaying a global (i.e., for all trackeddrivers) counters display page 86 (FIG. 7).

The verification block 82, also includes a pointer to the outstandingallocations table 84 ₁ set up for this driver 74 ₁. The outstandingallocations table 84 ₁ tracks specific information about each poolallocation that the driver has been given that remains outstanding,i.e., has not yet deallocated. The information includes the allocation'svirtual address, length, and information useful in debugging such asper-process caller information and the tag of the driver that allocatedthe memory, e.g., “TCP” for TCP/IP drivers.

To track pool allocations, each new allocation by the driver 74 ₁ addsinformation to its allocation table 84 ₁, while each deallocationremoves the information. Note that the information need not actually beerased from the table 84 ₁, as it is equivalent to effectively “remove”the information by marking it as deallocated. If the driver 74 ₁unloads, the driver verifier 70 examines the outstanding allocationstable 84 ₁ and issues a bug check if any memory allocated by the driverhas not been deallocated. In this manner, memory leaks are detected andcan be more easily debugged. The driver verifier 70 also attempts topage in all paged-out allocations by the driver 74 ₁ when the driver 74₁ is unloaded, making it easier to debug the driver 74 ₁.

Note that another driver may deallocate pooled memory for the driver 74₁. As understood from the above description, this deallocation by theother driver needs to be removed from the outstanding allocations table84 ₁, otherwise the system will incorrectly generate a bug check whenthe driver 74 ₁ unloads. In order for the outstanding allocations tableto properly reflect such a deallocation, at the time of allocation, anymemory allocated to a driver with pool tracking on is tagged (via bitsin the header). Anytime the kernel 64 deallocates memory with this tag,the driver verifier 70 is notified, whereby the allocation informationis located and properly removed the from the appropriate outstandingallocations table.

In addition to detecting memory leaks on unload, the driver verifier 70performs several other checks on unload. More particularly, the driververifier looks for undeleted timers, pending DPCs, undeleted lookasidelists, undeleted worker threads, undeleted queues and other similarresources that remain. To this end, the driver verifier 70 examinesresource lists 87 (FIG. 8) maintained by the kernel 64 to check whethera driver still has such items listed therefor. In this manner, checksare made to ensure that a driver being verified fully cleans up theseresources on unload, since failing to do so is known to cause crashesthat may be extremely difficult to debug.

While a driver is loaded, other information may be evaluated by a userthat may provide insight beyond that detected at unload time. Forexample, the user interface 60 is capable of displaying pool trackingdata 88 for a given driver while the driver is loaded. In oneimplementation, the pool tracking data is displayable via a propertypage that shows the statistics gathered from the driver verifier. Thecounters shown on the page are related to the pool tracking flag of theverifier and are mostly per-driver counters, (e.g., current allocations,current allocated bytes, and so forth), with the specific driver beingselectable via the user interface 60. In this manner, a tester mayexamine a loaded driver's usage of pooled memory, e.g., see to whetherrelatively many allocations are outstanding when only relatively few areexpected.

Other property pages are displayable, such as a “Driver Status” propertypage that provides an image of the current status of the driver verifier70. For example, a user can see a list of drivers of which the verifier70 is aware. The status can be “Loaded” (the driver is loaded andverified right now), “Unloaded” (the driver is not loaded now but it hasbeen loaded at least once since reboot), or “Never Loaded” (the driverwas never loaded, which may suggest that the driver's image file iscorrupted or that the user specified a driver name that is missing fromthe system). A user may also view the current types of verification thatare in effect.

The Global Counters property page 86 (FIG. 7) shows the current value ofsome of the counters maintained by the driver verifier 70. A zero valueof a counter can be an indication that the associated driver verifierflag is not enabled, e.g., if the Other/Faults injected (describedbelow) counter is zero, this is an indication that the low resourcesimulation flag is not enabled. In this manner, a user may monitor theactivity of the verifier 70 with the values of the counters updatingautomatically.

A settings page may be used to create and modify the driver verifier 70settings, which are saved in the registry 62 as described above. Theuser can use the list to view the currently installed drivers in thesystem. At present, each driver can be in four possible states,including “Verify Enabled”—the driver is currently verified—or “VerifyDisabled”—the driver is currently not verified—. The other possiblestates are “Verify Enabled” (Reboot Needed)—the driver will be verifiedonly after the next reboot—and “Verify Disabled” (Reboot Needed)—thedriver is currently verified but will not be verified after the nextreboot—. The user can select one or more drivers from the list andswitch the status. The user can also specify additional drivers to beverified after next reboot, such as when the user wants to install a newdriver that is not loaded already loaded. Lastly, a Modify Settingsproperty page is provided for dynamically changing volatile driververifier flags.

In accordance with another aspect of the present invention, the driververifier 70 examines the function calls of each selected driver tomonitor for certain actions that are forbidden. In one implementation,the driver verifier 70 performs this automatically for each driver beingverified, although this checking alternatively may be made selectable.More particularly, as represented in FIG. 9, function calls to thekernel have call parameters 92 and a requested operation associatedtherewith. The driver verifier 70 includes a parameter checkingcomponent 94 that essentially maintains a set of rules and otherinformation to validate the request and its parameters. For example,some straightforward violations include requesting a size zero memoryallocation, trying to deallocate (free) an address that was not returnedfrom an allocate request call or trying to free an address that wasalready freed. Also, a check is made to ensure that no illegal or random(uninitialized) parameter values are specified to certain kernel APIS.The driver verifier 70 issues a bug check if these or other suchviolations (described below) occur.

Another type of violation occurs when a driver attempts to raise orlower its interrupt request level (IRQL), i.e., by calling KeRaiseIrq1or KeLowerIrq1. For these types of calls, the driver verifier checksthat a raise IRQL really is a raise (i.e., the current IRQL is less thanthe target IRQL) or that a lower IRQL really is a lower IRQL.

Other IRQL-related errors occur when paged and non-paged poolallocations and deallocations are made at the incorrect IRQL. Paged poolallocations and deallocations need to be made at the asynchronousprocedure call level (APC_LEVEL) IRQL or below, while non-paged poolallocations and deallocations need to be made at the DISPATCH_LEVEL IRQLor below. Allocating or freeing paged pool at an IRQL above APC_LEVEL,or allocating or freeing non-paged pool at an IRQL above DISPATCH_LEVELis detected as a violation.

Still other detected violations include acquiring or releasing a fastmutex at an IRQL above APC_LEVEL, acquiring or releasing a spin lock atan IRQL other than DISPATCH_LEVEL, and double release of a spinlock.Mutexes and spinlocks are described in the aforementioned references“Inside Windows NT®” and “Inside Windows NT®, Second Edition.” Theseviolations similarly cause a bug check to be generated. Note that othertypes of violations may be added to those being monitored by theverifier 70.

In accordance with another aspect of the present invention, the driververifier can simulate extreme conditions, and thereby proactively forceerrors in a driver (e.g., 74) that may be otherwise difficult toreproduce. A first way in which is accomplished is to randomly fail poolallocation requests (and other APIs). To this end, (after seven minutesor some other duration following system startup so as to accuratelysimulate a low-memory condition), any allocation request calls placed ina certain time window are failed, while others outside the window arenot failed. For example, the driver verifier 70 may be configured tofail any call made within in a one-second interval (that restarts everyfifteen seconds), providing a generally psuedo-random nature to thefailures. Other intervals and periods may be used. The injection of suchallocation faults tests the driver's ability to react properly tolow-memory conditions. Note that allocation requests marked MUST_SUCCEED(a maximum of one page of MUST_SUCCEED pool is permitted) are notsubject to this action.

Another way in which errors may be forced is to place extreme memorypressure on the driver by invalidating its pageable code. Althoughkernel-mode drivers are forbidden to access pageable memory at a highIRQL or while holding a spin lock, such an action might not be noticedif the page has not actually been trimmed (i.e., paged-out). To detectthis, whenever the driver's IRQL is raised to DISPATCH_LEVEL or higher,or when a spin lock is requested, the driver verify marks the driver'spageable code and data (as well as system pageable pool, code, and data)as trimmed. Thus, any attempt by the driver to access this memoryindicates an attempt to access paged memory at the wrong IRQL, or whileholding a spin lock, whereby the driver verifier issues a bug check.

Note that drivers that are not selected for verification will not bedirectly affected by this memory pressure since their IRQL raises willnot cause this action. However, when a driver that is being verifiedraises the IRQL, the driver verifier 70 trims pages which may be used bydrivers that are not being verified. As a result, errors by drivers thatare not being verified may occasionally be detected by this action.

Another aspect of the driver verifier 70 is that it is extensible andprovides APIs so that other drivers can provide “mini-verifiers” fortheir subcomponents. For example, not all kernel drivers (e.g., displaydrivers, kernel-mode printer drivers, network mini-port drivers) areallowed to call the kernel directly for allocating pool. Because of thisdifference, the driver verifier treats graphics drivers somewhatdifferently than it treats other kernel-mode drivers.

By way of example, as generally shown in FIG. 10, kernel-mode graphicsdrivers 96 and print drivers do not allocate pool directly, but insteadallocate pool via callbacks to GDI (Graphical Device Interface) serviceroutines 98 (e.g., exported by win32k.sys in Windows® 2000). Forexample, EngAllocMem is the callback that a graphics driver 96 calls toexplicitly allocate pool memory, and other specialized callbacks such asEngCreatePalette and EngCreateBitmap return pool memory as well.

To provide the above-described automated testing for the graphicsdrivers (e.g., 96), support for some of the driver verifier functionshave been incorporated into the GDI 98, i.e., via API calls to thedriver verifier 70, the GDI 98 may use the driver verifier facility tofurther verify video and print drivers. Note that the “ndis.sys” drivermay do the same for network miniport drivers. Further, note that thedriver verifier 70 may be set to verify the GDI driver 98 itself,although this has the effect of verifying all graphics driverssimultaneously, and thus to obtain more specific information about agraphics driver, the driver itself may be verified directly.

However, because graphics drivers are more restricted than otherkernel-mode drivers, they require only a subset of the driver verifierfunctionality. For example, IRQL checking and I/O verification are notneeded, and thus the above-described automatic checks which the driververifier 70 usually performs (e.g., verification of IRQL and memoryroutines, checking freed memory pool for timers, and checking on driverunload) are not made when verifying a graphics driver. Similarly, theforce IRQL checking option and I/O verifier option (described below) arenot used for graphics drivers, and if selected, have no effect.

The other functionality provided by the driver verifier 70, namely usingspecial pool, random failure of pool allocations, and pool tracking, aresupported in the different graphics GDI callbacks. Table 2 lists thefollowing GDI callback functions that are subject to the random failuretest:

TABLE 2 EngAllocMem EngAllocUserMem EngCreateBitmapEngCreateDeviceSurface EngCreateDeviceBitmap EngCreatePaletteEngCreateClip EngCreatePath EngCreateWnd EngCreateDriverObjectBRUSHOBJ_pvAllocRbrush CLIPOBJ_ppoGetPath

By way of summary, the general operation of the present invention isdescribed below with respect to the flow diagrams of FIGS. 11–15. Itshould be understood, however, that the flow diagrams should not beconsidered as representing the actual code, but instead are simplifiedand provided to summarize the various functions and tests performed bythe driver verifier 70.

Step 1100 of FIG. 11 represents a call coming in from a driver (e.g. 74)to the kernel 64. At step 1102, the re-vectoring component 68 determineswhether the driver is one that is being verified. If not, step 1104represents the providing of the call to the kernel 64, to handle as aregular request. If however the re-vectoring component 68 determinesthat the call is to be re-vectored, it passes the call to the driververifier 70 at step 1106.

FIGS. 12–14 represent the various tests performed by the verifier oncethe verifier 70 receives the call and the testing information from there-vectoring component 68 (step 1200). At step 1202, the driver verifier70 tests the call parameters against the various above-described rulesto ensure that no violations have occurred. If a violation is found, abug check is issued as represented via steps 1204–1206. This ordinarilyshould crash the system, however it is feasible that in some situationsit might be desirable to continue testing (as represented by the dashedline from step 1206 to step 1208.

If no errors are found (or testing is to continue despite an error),step 1208 is executed and represents the checking of the bitfield valuefor the driver level key to determine if random failures are enabled,along with a check as to whether the request corresponds to a requestfor pooled memory. If not, the process branches to the next test (asrepresented by FIG. 13). If so, step 1208 branches to step 1210 todetermine if it is time for a random failure, e.g., after seven minutesand in the correct time interval, as described above. If it is time toinject a failure, step 1210 branches to step 1212 where an out-of-pooledmemory error or the like is returned, after which the testing processends. Otherwise, step 1210 continues to the next test (FIG. 13).

Step 1300 of FIG. 13 represents the testing by the driver verifier 70 ofwhether the bitfield value for the driver level key specifies that thespecial pool 80 should be used for this driver. If not, step 1300advances to the next test (represented in FIG. 14). If the special pool80 is to be used, step 1300 branches to step 1302 to determine whetherthe call corresponds to an allocation request or a deallocation request.If a deallocation request, step 1302 branches to step 1304 where asdescribed above, the deallocated memory page is marked as “No Access” todetect post-deallocation read-write access errors. If instead anallocation request is being made, step 1302 branches to step 1306 wherethe memory (if available) is allocated from the special pool 80 bylocating a page and returning a pointer to appropriate virtual locationtherein as described above. If space in the special pool was available,the page before and after the allocated page is marked as “No Access” tobound the allocated memory location, as also described above.

Step 1400 of FIG. 14 represents the evaluation of the bitfield value todetermine if pool allocation tracking is on for this driver. If not,step 1400 branches to FIG. 15 for the next test, otherwise step 1400branches to step 1402 to determine whether the call is an allocationrequest or a deallocation request. If a deallocation request, step 1402branches to step 1404 to remove the allocation information form theoutstanding allocations table for this driver. If an allocation request,step 1402 branches to step 1406, which represents the setting up of averification block and corresponding outstanding allocations table forthis driver if this is the first allocation requested by this driver.Note that alternatively, the verification block and correspondingoutstanding allocations table may be set up for each driver to be testedfor pool allocation tracking when the registry copy 66 is first read. Inany event, step 1410 represents the updating of the various allocationcounts (e.g., the total allocations count in the verification block) andthe adding of the allocation information to the outstanding informationtable for this driver.

FIG. 15 next represents the memory pressure test, which if active asdetermined by step 1500, results in the invalidating (step 1502) of thedriver's pageable code and data, and the system paged pool code and dataas described above.

Once the various tests are established, the driver verifier 70 candetect driver errors and can issue appropriate bug checks. Table 3 belowsummarizes errors and bug check values issued therefor:

TABLE 3 IRQL_NOT_LESS_OR_EQUAL 0xA PAGE_FAULT_IN_NONPAGED_AREA 0x50ATTEMPTED_WRITE_TO_READONLY_MEMORY 0xBESPECIAL_POOL_DETECTED_MEMORY_CORRUPTION 0xC1DRIVER_VERIFIER_DETECTED_VIOLATION 0xC4DRIVER_CAUGHT_MODIFYING_FREED_POOL 0xC6 TIMER_OR_DPC_INVALID 0xC7DRIVER_VERIFIER_IOMANAGER_VIOLATION 0xC9 (described below)

Lastly, it can be readily appreciated that the driver verifier 70further provides a foundation for adding additional features in thefuture. In general, the driver verifier architecture is directed tomaking it easier for driver writers to validate their products, forsystems to run much more reliably and to provide an easy definitive wayto troubleshoot problems when they do occur. One such way in which thepresent invention may be extended is through an I/O verifier 100 thatenables special IRP verification, as generally represented in FIG. 16.

The I/O Verifier

The I/O verifier 100 tests for driver errors wherein I/O is accomplishedby sending I/O Request Packets (IRPs) 102 to a stack of drivers 104managing a particular piece of hardware. The proper handling of IRPs isrequired for a stable and functional operating system. In general, theI/O verifier 100 operates by activating hooks in the kernel 64 thatallow it to monitor the IRP traffic throughout the system. The I/Overifier 100 also changes the manner in which I/O travels throughout thesystem, setting a series of traps to immediately catch errant behavior.

The I/O verifier 100 hooks functions that drivers call to manipulateIRPs. The functions are set forth in TABLE 4:

TABLE 4 IofCallDriver Sends or forwards and IRP to a driverIofCompleteRequest Finishes an IRP IoAllocateIRP These functions createIRPs IoBuildSynchronousFsdRequest IoBuildAsynchronousFsdRequestIoBuildDeviceIoRequest IoFreeIrp Frees IRP IoInitializeIrp InitializesIRP IoCancelIrp Cancels IRP

In order to monitor the driver stacks 104 that receive IRPs 102 and tocatch other bugs, the I/O verifier 100 also hooks the functions setforth in TABLE 5 below:

TABLE 5 IoAttachDeviceToDeviceStack Adds driver to stack that receivesIRPs. IoDetachDevice (removes driver from stack that receives IRPs)IoDeleteDevice (removes an instantiation of a driver from memory)IoInitializeTimer (initializes a timer for a given driver stack)

The manner in which the IO verifier “hooks” these functions depends onwhether the kernel 64 makes internal use of the routine. Two methods areavailable.

In the re-vectoring method, a drivers' requests to get an address for akernel function at load-time are monitored. If the function and driverare to be hooked, an alternate function is supplied by a re-vectoringcomponent for the driver being verified. Re-vectoring monitors load-timefixups between different components. As such, one disadvantage ofre-vectoring is that it does not catch a component's call to itself.However, for certain functions the kernel reliance is not an issue,namely the IoInitializeTimer, IoBuildSynchronousFsdRequest,IoBuildAsynchronousFsdRequest and IoBuildDeviceIoRequest functions. Assuch, the I/O Verifier 100 hooks these functions via re-vectoring.

The second hooking technique requires the kernel 64 to supply hooks inits own functions, because kernel reliance on the remaining functions isan issue, as the entire lifetime of an IRP needs to be monitored. Thesecond technique is thus used on these other functions, i.e., eachfunction has a special callout available to the I/O Verifier 100.

The lifetime of an IRP starts when the IRP is allocated. Next, therequest is written into the IRP and the IRP is sent to a driver 102.That driver either forwards the request to another driver, handles therequest entirely within itself, or modifies the request before sendingit on to another driver. Note that the request is independent of thecall stack, as a driver in the stack 104 may choose to “pend” an IRP,i.e., to tell the initiator of the request that the call will becompleted later.

To track IRPs throughout the system, the I/O verifier 100 maintains aset of structures that mirror the various aspects of an IRP. When an IRPis allocated, a tracking structure (IOV_REQUEST_PACKET) is created. Thisstructure tracks the memory that encapsulates the IRP. AnIOV_REQUEST_PACKET is “active” whenever the corresponding IRP may besent to a driver. The IOV_REQUEST_PACKET is “non-active” when thecorresponding IRP has been freed, but the trackable aspects of the IRPhave not abated. When no trace of the IRP remains in the system, theIOV_REQUEST_PACKET becomes “dead” and the underlying structure is freed.

When the new IRP is sent to a stack, the request therein is noticed. Inresponse, the I/O Verifier 100 creates a structure (IOV_SESSION_DATA) totrack it, and attaches it to the IOV_REQUEST_PACKET that corresponds tothe IRP. The IOV_SESSION_DATA is “alive” when the request is beingprocessed by drivers. When the request is completed, theIOV_SESSION_DATA is marked “non-active.” When the request is completedand all call stacks used to process the request have unwound, therequest is marked “dead” and the IOV_SESSION_DATA tracking structure isfreed.

The lifetimes of the IOV_REQUEST_PACKET and the IOV_SESSION_DATA areindependent. If an IRP is created and immediately freed without everbeing sent to a stack, an IOV_SESSION_DATA structure is never created.If the IRP is recycled upon completion of a request of a request, theIOV_REQUEST_PACKET may pick up a new “active” IOV_SESSION_DATA beforethe old “non-active” IOV_SESSION_DATA transitions to the “dead” state.Alternately, the IRP may be freed immediately upon completion of therequest, in which case both the IOV_SESSION_DATA and the IOV_REQUESTPACKET will be “non-active”.

At present, when I/O verifier is enabled for a driver, the I/O verifier100 detects forty different failures within drivers. These failures maybe divided into two levels, in which Level 1 is a subset of Level 2 asset forth in TABLE 6 below:

TABLE 6 Verifier level 1 detects: 1) Drivers calling IoFreeIrp oninvalid or freed IRPs. 2) Drivers calling IoFreeIrp on IRPs that arestill associated with a thread and thus will be freed when completed. 3)Drivers calling IoCallDriver with invalid or freed IRPs. 4) Driverscalling IoCallDriver with invalid or freed device objects. 5) Drivershaving dispatch routines that return at IRQLs other than that at whichthey were called. 6) Drivers that complete IRPs that were alreadycompleted. 7) Drivers that forget to remove cancel routines beforecompleting IRPs. 8) Drivers that complete with −1 or STATUS_PENDING(which is illegal). 9) Drivers that complete IRPs from within theirISRs. 10) Drivers that pass bogus fields to the IoBuild . . . Irpfunctions. 11) Drivers that reinitialize timer fields. Verifier level 2detects the above items and also: 12) Drivers that delete their deviceobjects without first detaching them from the stack. 13) Drivers thatdetach device objects from a stack when they were never attached toanything in the first place. 14) Drivers that forget to remove cancelroutines before forwarding IRPs. 15) Drivers that forward or completeIRPs not currently owned by them. 16) Drivers that copy entire stacklocations and inadvertantly copy the completion routine. 17) Driversthat free IRPs currently in use. 18) Drivers that call IoInitializeIrpon IRPs allocated with Quota. 19) Drivers that fail to properlyinitialize IRP statuses. 20) Drivers that forward IRPs directly to thebottom on a stack. 21) Drivers that respond to IRPs to which they shouldnot respond. 22) Drivers that forward failed IRPs where inappropriate.23) Drivers that reset IRPs statuses that they should not reset. 24)Drivers that do not handle required IRPs. 25) Drivers that fail todetach their device objects from the stack at the appropriate time 26)Drivers that fail to delete their device objects at the appropriate time27) Drivers that don't fill out required dispatch handlers 28) Driversthat don't properly handle WMI IRPs 29) Drivers that delete deviceobjects at inappropriate times 30) Drivers that detach their deviceobjects at inappropriate times 31) Drivers that return statusesinconsistent with what the completion routine above them saw. 32)Drivers that return bogus or uninitialized values from their dispatchroutines. 33) Drivers that return synchronously but forget to completean IRP 34) Drivers that set pageable completion routines 35) Driversthat forget to migrate the pending bit in their completion routines 36)Drivers that forget to reference device objects where appropriate. 37)Drivers that complete IRPs without forwarding them where inappropriate.38) Drivers that incorrectly fill out certain PnP IRPs. 39) Drivers thatcreate IRPs that are reserved for system use only. 40) Drivers that callIoCallDriver at invalid IRQLs, based on the major code.

Many of these checks (e.g., checks numbered 1–9, 11–14, 18, 27 and 40)involve spot checking various fields when a driver calls one of themonitored functions. These checks typically use the re-vectoringtechnique.

The remainder of the checks depend on complete knowledge of the IRP asit traveled throughout the system. For example, the check numbered 17detects that an IRP has been freed when in use by checking to see if anIRP has an “active” IOV_SESSION_DATA structure associated with it.

In addition to monitoring I/O, The I/O verifier 100 actively changes theway in which I/O travels throughout the system to flush out errantbehavior and make such behavior more-readily detectable.

First, the I/O verifier 100 allocates IRPs from a special pool. Asdescribed above, special pool memory may be set by the I/O verifier 100to detect attempts to access freed memory, and to detect over-writes.Both of these mistakes are common in IRP usage. To this end, when I/OVerifier is enabled (via the bitfield for a driver), all IRPs obtainedthrough IoAllocateIrp are allocated from a special pool and their use istracked.

Second, when a driver finishes with a request, the memory backing theIRP is typically still valid. Drivers that erroneously touch the IRPafter completion may or may not corrupt memory in an easily detectablemanner. The use of the special pool alone does not always catch thisbug, as the IRP is often recycled instead of freed upon completion. Tocatch this, the I/O verifier 100 creates a copy of the IRP, called asurrogate, each time the IRP is forwarded. Upon completion of thesurrogate, the original IRP is updated and the surrogate is immediatelyfreed. If the surrogate IRP is allocated via special pool, then theabove-mentioned bugs are immediately detected. Surrogate IRPs have theirown IOV_REQUEST_PACKET tracking data, and the structure refers back tothe IOV_REQUEST_PACKET associated with the original IRP.

Third, the driver handling the request may choose to return before theoperation is completed. This is called “pending” an IRP. Drivers oftensend IRPs down their stack and do some processing when the IRP comesback up the stack. However, many fail to wait if the IRP was not handledsynchronously (i.e., the IRP is still pending). To catch these bugs theI/O verifier 100 makes the IRPs appear to be handled asynchronously.While doing so, the I/O verifier 100 ensures that the IRP is notaccessible, whereby erroneous behavior is immediately detectable.

Fourth, the code at a higher IRQL must finish before code at a lowerIRQL is scheduled. IRPs may be completed at any IRQL between zero (0)and two (2). A common bug in drivers is to access pageable memory duringcompletion of an IRP. Such an operation is illegal if the IRP iscompleted at level two (2). To flush out this type of bug, the I/Overifier 100 can choose to complete all IRPs at any level between 0 and2.

Fifth, when completing an IRP, a driver must return an identical statusin two different places. Drivers often make the mistake of returning twodifferent statuses, one from the driver stack beneath them and one oftheir own. Unfortunately, such bugs are hard to detect, as typically thestack beneath them will use a matching return code. To flush these bugsout, the I/O verifier 100 may change the returned status of a driver bycontinually adding one (1) to the code at each layer. This technique iscalled status rotation.

Sixth, drivers sometimes return uninitialized status codes. In such anevent, the code returned is read from a location on the call stack, witha value that is essentially random. Before calling into a driver, theI/O verifier 100 may first pre-initialize future stack locations to aknown illegal value. If that value is returned after calling the driver,then this bug is immediately detected.

As can be seen from the foregoing detailed description, there isprovided a method and system for monitoring and verifying drivers. Themethod and system are flexible, efficient, extensible and help detect(and produce) numerous errors in various types of drivers, therebysignificantly helping to increase the reliability of a system. Indeed,in actual implementations, computer systems having verified drivers haveincreased reliability on the order of thirty to forty percent. Moreover,because no re-compilation or changes of any kinds to the target driversare required (i.e., the driver verifier can take action on unmodifieddriver binaries), the present invention provides an invaluable tool forsystem administrators and so forth, (as well as developers), as they caneasily verify drivers on existing systems without having to install anentire checked (i.e., debug) build, or indeed, debug components of anytype.

While the invention is susceptible to various modifications andalternative constructions, certain illustrated embodiments thereof areshown in the drawings and have been described above in detail. It shouldbe understood, however, that there is no intention to limit theinvention to the specific form or forms disclosed, but on the contrary,the intention is to cover all modifications, alternative constructions,and equivalents falling within the spirit and scope of the invention.

1. In a computer system, a method, comprising: receiving a request froma kernel mode driver, wherein the request is a function call in a kernelcomponent of an operating system; determining that the kernel modedriver is to be monitored, wherein determining that the kernel modedriver is to be monitored includes checking a registry setting;re-vectoring the request to a kernel mode driver verifier; and takingaction in the kernel mode driver verifier to actively test the kernelmode driver for errors, wherein the kernel mode driver verifier iscapable of testing the kernel mode driver by simulating a low resourcecondition including failing requests for memory pool allocation.
 2. Themethod of claim 1 wherein the request from the kernel mode driverincludes a memory allocation request, and wherein taking action in thekernel mode driver verifier to test the kernel mode driver includesallocating memory space thereto from a special pool of memory.
 3. Themethod of claim 1 wherein the request from the kernel mode driverincludes a memory allocation request, and wherein taking action in thekernel mode driver verifier to test the kernel mode driver includesmarking memory bounding the memory space to detect improper access ofthe memory bounding the memory space.
 4. The method of claim 1 whereinthe request from the kernel mode driver includes a memory deallocationrequest, and wherein taking action in the kernel mode driver verifier totest the kernel mode driver includes marking deallocated memory space todetect improper access of the deallocated memory space.
 5. The method ofclaim 1 wherein taking action in the kernel mode driver verifier to testthe kernel mode driver includes maintaining allocation information in atleast one data structure associated with the kernel mode driver.
 6. Themethod of claim 5 wherein the request from the kernel mode driverincludes a memory allocation request, and wherein maintaining allocationinformation includes adding data corresponding to the allocation requestto the data structure.
 7. The method of claim 5 wherein the request fromthe kernel mode driver includes a memory deallocation request, andwherein maintaining allocation information includes removing datacorresponding to the allocation request from the data structure.
 8. Themethod of claim 5 further comprising providing the allocationinformation to a user interface.
 9. The method of claim 1 wherein takingaction in the kernel mode driver verifier to test the kernel mode driverincludes validating call parameters.
 10. The method of claim 1 whereintaking action in the kernel mode driver verifier to test the kernel modedriver includes checking for resources allocated to the kernel modedriver at kernel mode driver unload.
 11. The method of claim 1 whereintaking action in the kernel mode driver verifier to test the kernel modedriver includes simulating a low resource condition.
 12. The method ofclaim 11 wherein simulating the low resource condition includesinvalidating kernel mode driver code and data.
 13. The method of claim 1wherein taking action in the kernel mode driver verifier to test thekernel mode driver includes checking for timers in deallocated pooledmemory.
 14. A computer-readable medium having computer-executableinstructions, comprising instructions for: receiving a request from akernel mode driver for allocation of memory space; determining that thekernel mode driver is to be monitored, wherein determining that thekernel mode driver is to be monitored includes checking a registrysetting; determining a location of memory space to allocate;re-vectoring the request to a kernel mode driver verifier; in the kernelmode driver verifier, testing the kernel mode driver including markingthe memory bounding the memory space to detect improper access of thememory bounding the memory space; allocating the memory space; andmonitoring the areas bounding the location for an access violation usingthe kernel mode driver verifier.
 15. The computer-readable medium ofclaim 14 having further computer-executable instructions, comprising,instructions for detecting an access violation.
 16. Thecomputer-readable medium of claim 14 having further computer-executableinstructions, comprising instructions for receiving a request fromkernel mode driver for deallocation of the memory space; restrictingaccess to deallocated memory space, wherein any access request to thedeallocated memory space results in an access violation; and monitoringthe deallocated memory space for an access violation.
 17. Thecomputer-readable medium of claim 16 having further computer-executableinstructions, comprising, instructions for detecting an access violationin the deallocated memory space.
 18. A computer-readable medium havingcomputer-executable instructions, comprising instructions for: receivinga plurality of requests from a kernel mode driver for allocation ofvarious distinct sets of memory; allocating the memory; determining thatthe kernel mode driver is to be monitored, wherein determining that thekernel mode driver is to be monitored includes checking a registrysetting; tracking the memory allocated to the kernel mode driver on eachrequest; receiving requests for deallocation of at least one of the setsof memory allocated to the kernel mode driver; tracking the memorydeallocated in each received deallocation request; determining from thetracking whether memory remains allocated to the kernel mode driver at atime when the driver should have no memory allocated thereto; andgenerating an error at the time if memory remains allocated.
 19. Asystem for monitoring, kernel mode drivers, comprising: an operatingsystem component including an interface for receiving requests fromkernel mode drivers; a re-vectoring component for examining the requeststo determine whether requesting kernel mode drivers are to be monitored,wherein the determining whether the requesting kernel mode drivers areto be monitored is based on a setting in a registry; and a kernel modedriver verifier component operably connected to the re-vectoringcomponent, the driver verifier receiving information from there-vectoring component for a kernel mode driver that is to be monitoredand executing at least one test to monitor the kernel mode driver,wherein in response to a request for memory from the kernel mode driver,the kernel mode driver verifier component allocates memory for thekernel mode driver to use from a pool of memory other than a memory poolnormally allocated from when the driver is operating unmonitored. 20.The system of claim 19 wherein the operating system component comprisesa kernel component.
 21. The system of claim 19 further comprising a userinterface for writing driver information to the registry.
 22. The systemof claim 19 wherein a request from the kernel mode driver includes amemory allocation request, and wherein a test by the kernel mode driververifier includes allocating memory space thereto from a special pool ofmemory, and marking memory bounding the memory space to detect improperaccess of the memory bounding the memory space.
 23. The system of claim19 wherein a request from the kernel mode driver includes a memorydeallocation request, and wherein a test by the kernel mode driververifier includes deallocating the memory space, and marking thedeallocated memory space to detect improper access thereof.
 24. Thesystem of claim 19 wherein a test by the kernel mode driver verifierincludes examining resources allocated to the kernel mode driver. 25.The system of claim 24 wherein examining resources allocated to thekernel mode driver includes tracking outstanding memory allocated to thekernel mode driver.
 26. The system of claim 24 wherein examiningresources allocated to the kernel mode driver includes reviewing listsmaintained by the operating system component for information thereinassociated with the kernel mode driver.
 27. The system of claim 19wherein a test performed by the kernel mode driver includes validatingcall parameters.
 28. The system of claim 19 wherein a test performed bythe kernel mode driver includes failing requests for memory poolallocation.
 29. The system of claim 19 wherein a test performed by thekernel mode driver includes invalidating driver code and data.
 30. Thesystem of claim 19 wherein a test performed by the kernel mode driverincludes checking for timers in deallocated pooled memory.
 31. In acomputer system, a method for verifying a plurality of kernel modedrivers, comprising: selecting one or more tests for verifyingfunctionality of one of the kernel mode drivers; determining that one ofthe kernel mode driver is to be monitored, wherein determining that thekernel mode driver is to be monitored includes checking a registrysetting; modifying a request for system services by re-vectoring therequest to include execution of the selected tests to a kernel modedriver verifier, wherein one of the tests includes restricting access toa resource, such that an attempted access to the resource causes anaccess violation; executing the modified request; and generating errorsfor any test failures.
 32. The method of claim 31 wherein the kernelmode driver comprises a device driver.
 33. The method of claim 31further comprising applying a test condition designed to detect aspecific error.
 34. The method of claim 33 wherein applying the testcondition includes restricting available system resources.
 35. Acomputer-readable medium having computer-executable instructions,comprising instructions for verifying kernel mode drivers: selecting oneor more tests for verifying functionality of one of the kernel modedrivers; determining that the kernel mode driver is to be monitored,wherein determining that the kernel mode driver is to be monitoredincludes checking a registry setting; modifying a request for systemservices by re-vectoring the request to include execution of theselected tests to a kernel mode driver verifier, wherein one of thetests includes restricting access to a resource, such that an attemptedaccess to the resource causes an access violation; executing themodified request; and generating errors for any test failures.